package com.itranswarp.learnjava;

import java.util.Scanner;

/**
 * switch实现石头/剪子/布并判断胜负
 */
public class Main {

	public static void main(String[] args) {
		System.out.println("please choice:");
		System.out.println(" 1: Rock");
		System.out.println(" 2: Scissors");
		System.out.println(" 3: Paper");
		// 用户输入:
		int choice = 0;
		// 计算机随机数 1, 2, 3:
		int random = 1 + (int) Math.random() * 3;
		System.out.print("请输入数字1-3\n**************1.石头2.剪子3.布**************\n");
		Scanner in = new Scanner(System.in);
		int yh = in.nextInt();
		//用户输入选择
		switch(yh)
		{
		case 1:
			System.out.print("您出了石头\n");
			break;
		case 2:
			System.out.print("您出了剪子\n");
			break;
		case 3:
			System.out.print("您出了布\n");		
			break ;					
		}
		switch(random)
		{
		case 1:
			System.out.print("系统出了石头\n");
			break;
		case 2:
			System.out.print("系统出了剪子\n");
			break;
		case 3:
			System.out.print("系统出了布\n");		
			break ;					
		}
		int c = yh - random - 1;
		switch(c)
		{
		case 0:
			System.out.print("平局");
			break;				   
		case -1:
		case 2:
			System.out.print("恭喜你！你赢了");
			break;				   
		case 1:
		case -2:
			System.out.print("很抱歉，你输了");
			break;			

		}		
	}

}
